﻿using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;

namespace DataGrid_Dashbo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            var converter = new BrushConverter();
            ObservableCollection<Member> members = new ObservableCollection<Member>();
            //Create DataGrid Items Info
            members.Add(new Member { Number ="1",Character="a",BgColor = (Brush)converter.ConvertFromString("#1098ad"), Name = "Jack", Position = "BeiJing", Phone = "1313141",Email="133141@dda.com"});
            members.Add(new Member { Number = "2", Character = "b", BgColor = (Brush)converter.ConvertFromString("#1e88e5"), Name = "Tom", Position = "AnHui", Phone = "4556", Email = "" });
            members.Add(new Member { Number = "3", Character = "c", BgColor = (Brush)converter.ConvertFromString("#ff8f00"), Name = "Ash", Position = "TianJing", Phone = "23", Email = "" });
            members.Add(new Member { Number = "4", Character = "d", BgColor = (Brush)converter.ConvertFromString("#ff5252"), Name = "Uzi", Position = "ChongQing", Phone = "23", Email = "" });
            members.Add(new Member { Number = "5", Character = "e", BgColor = (Brush)converter.ConvertFromString("#0ca678"), Name = "Ale", Position = "ShangHai", Phone = "134", Email = "" });
            members.Add(new Member { Number = "6", Character = "f", BgColor = (Brush)converter.ConvertFromString("#6741d9"), Name = "XiaoHu", Position = "FuJian", Phone = "314", Email = "" });
            members.Add(new Member { Number = "7", Character = "g", BgColor = (Brush)converter.ConvertFromString("#ff6f00"), Name = "Faker", Position = "YunNan", Phone = "4234", Email = "" });
            members.Add(new Member { Number = "8", Character = "h", BgColor = (Brush)converter.ConvertFromString("#ff5252"), Name = "Simple", Position = "XinJiang", Phone = "1313", Email = "" });
            members.Add(new Member { Number = "9", Character = "i", BgColor = (Brush)converter.ConvertFromString("#1e88e5"), Name = "KaZe", Position = "NeiMengGu", Phone = "5645", Email = "" });
            members.Add(new Member { Number = "10", Character = "j", BgColor = (Brush)converter.ConvertFromString("#0ca678"), Name = "Leon", Position = "ShanXi", Phone = "67575", Email = "" });

            membersDataGrid.ItemsSource = members;
        }

        private void Border_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left) { 
                this.DragMove();
            }
        }

        private bool IsMaximized = false;
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 2) {
                if (IsMaximized)
                {
                    this.WindowState = WindowState.Normal;
                    this.Width = 1080;
                    this.Height = 720;
                    IsMaximized = false;
                }
                else { 
                    this.WindowState = WindowState.Maximized;
                    IsMaximized = true;
                }
            }
        }

 
    }

    public class Member { 

        public string Character { get; set; }
        public string Number { get; set; }
        public string Name { get; set; }
        public string Position { get; set; }
        public string Email { get; set; }
        public string Phone { get; set; }
        public Brush BgColor { get; set; }

    }
}
